import request from "@/config/request/index";
import type {InventionCode} from "@/api/invention/model";

enum API {
    root = '/member/invention/code'
}

/**
 * 创建邀请码
 */
export function createInventionCode() {
    return request.post<BaseResult<InventionCode>>({
        url: `${API.root}/create`
    })
}

/**
 * 获取邀请码
 */
export function getInventionCode() {
    return request.get<BaseResult<InventionCode>>({url: API.root})
}

/**
 * 获取微信推广码
 */
export function getInventionWxQrcode() {
    return request.get<BaseResult<String>>({url: `${API.root}/wx-qrcode-url`})
}

/**
 * 扫描微信推广码
 */
export function scanInventionCode(inventionCode: string) {
    return request.put<BaseResult<void>>({
        url: `${API.root}/scanned`,
        data: {inventionCode}
    })
}

/**
 * 绑定被推广用户
 */
export function bindInviteeCode(inventionCode: string) {
    return request.post<BaseResult<void>>({
        url: `${API.root}/bind`,
        data: {inventionCode}
    })
}
